package com.dao;
import java.sql.*;
import java.util.HashMap;



import com.pojo.job;

public class jobDb extends DbConn{
 public HashMap<String, job> selectJob()
 {
	 HashMap<String,job> jobs=new HashMap<String,job>();
	 if (conn!=null) {
		try {
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select * from total");
		 while(rs.next()) {
			 job job=new job();

			 job.setJob_name(rs.getString("job_name").trim());
			 job.setJob_company(rs.getString("job_company").trim());
			 job.setWage(rs.getString("wage").trim());
			 job.setPosition(rs.getString("position").trim());
			 job.setJob_info(rs.getString("job_info").trim());
			 job.setJob_desc(rs.getString("job_desc").trim());
			 jobs.put(job.getJob_name(),job);
		 }
		 rs.close();
		}
		 catch(SQLException ex) {
		 System.err.println(ex.getMessage());
		 }
 }
return jobs;
 }

 public HashMap<String,job> searchJobByName(String job_name)
 {
	 HashMap<String,job> jobs=new HashMap<String,job>();
	 if (conn!=null) {
		try {
			job_name="%"+job_name+"%";
			String sql="select * from total where job_name like ?";
			PreparedStatement pstmt=conn.prepareStatement(sql);
			pstmt.setString(1,job_name);
			ResultSet rs=pstmt.executeQuery();
		
		 while(rs.next()) {
			job job=new job();

			 job.setJob_name(rs.getString("job_name").trim());
			 job.setJob_company(rs.getString("job_company").trim());
			 job.setWage(rs.getString("wage").trim());
			 job.setPosition(rs.getString("position").trim());
			 job.setJob_info(rs.getString("job_info").trim());
			 job.setJob_desc(rs.getString("job_desc").trim());
			 jobs.put(job.getJob_name(),job);
		 }
		 rs.close();
		}
		 catch(SQLException ex) {
		 System.err.println(ex.getMessage());
		 }
 }
	 return jobs;
 }

}
